<?php
//@@提交函数
function zhang($curl,$curlPost){
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$curl);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$curlPost);
$data=curl_exec($ch);
curl_close($ch);
return $data;
}
//@@@获取IP函数
function ip(){
if (getenv("HTTP_CLIENT_IP")&&strcasecmp(getenv("HTTP_CLIENT_IP"),"unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR")&&strcasecmp(getenv("HTTP_X_FORWARDED_FOR"),"unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR")&&strcasecmp(getenv("REMOTE_ADDR"),"unknown"))
$ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR'])&&$_SERVER['REMOTE_ADDR']&&strcasecmp($_SERVER['REMOTE_ADDR'],"unknown"))
$ip = $_SERVER['REMOTE_ADDR'];
else
$ip ="unknown";
return($ip);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
function tesy_key($str,$encrypt_key){
	$encrypt_key=md5($encrypt_key);
	$ctr=0;
	$tmp='';
	for($i=0;$i<strlen($str);$i++){
		$ctr=$ctr==strlen($encrypt_key)?0:$ctr;
		$tmp.=$str[$i] ^ $encrypt_key[$ctr++];
	}
	return $tmp;
}
function addqqwyzm($qqhao,$qqmima){
$post_data = array(
'qq='.$qqhao,
'pwd='.$qqmima,
'bid_code=3GQQ',
'toQQchat=true',
'login_url=http://pt.3g.qq.com/s?aid=nLoginnew&q_from=3GQQ',
'modifySKey=0',
'loginType=1',
'aid=nLoginHandle',
);
$post_data = implode('&',$post_data);
$url='http://pt.3g.qq.com/psw3gqqLogin?r=777151794&vdata='.md5(time());
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
//传递一个作为HTTP“POST”操作的所有数据的字符串。
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$out=curl_exec($ch);
curl_close($ch);
return $out;
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
function tesy_decrypt($str,$key='TesyTeam'){
	$str=tesy_key(base64_decode($str),$key);
	$tmp='';
	for($i=0;$i<strlen($str);$i++){
		$md5=$str[$i];
		$tmp.=$str[++$i] ^ $md5;
	}
	return $tmp;
}
function addqqyyzm($qqhao,$qqmima,$r,$extend,$r_sid,$sid,$ip,$hidpw,$verify){
$post_data = array(
'qq='.$qqhao,
'pw='.$qqmima,
'u_token='.$qqhao,
'hexpwd='.$hidpw,
'sidtype=1',
'hexp=true',
'auto=0',
'modifySKey=0',
'q_status=20',
'r='.$r,
'loginType=3',
'imgType=gif',
'extend='.$extend,
'r_sid='.$r_sid,
'bid_code=qqchatLogin',
'toQQchat=falsh',
'rip='.$ip,
'verify='.$verify,
'bid=0',
);
$post_data = implode('&',$post_data);
$url='http://pt.3g.qq.com/handleLogin?sid='.$sid.'&amp;vdata=';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$out=curl_exec($ch);
curl_close($ch);
return $out;
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
function tesy_encrypt($str,$key='TesyTeam'){
	srand((double)microtime() * 1000000);
	$encrypt_key=md5(rand(0, 32000));
	$ctr=0;
	$tmp='';
	for($i=0;$i<strlen($str);$i++){
		$ctr=$ctr==strlen($encrypt_key)?0:$ctr;
		$tmp.=$encrypt_key[$ctr].($str[$i] ^ $encrypt_key[$ctr++]);
	}
	return base64_encode(tesy_key($tmp,$key));
}
function newsid($qqhao,$qqmima){
$post_data = array(
'qq='.$qqhao,
'pwd='.$qqmima,
'bid_code=3GQQ',
'toQQchat=true',
'login_url=http://pt.3g.qq.com/s?aid=nLoginnew&q_from=3GQQ',
'modifySKey=0',
'loginType=1',
'aid=nLoginHandle',
);
$post_data = implode('&',$post_data);
$url='http://pt.3g.qq.com/psw3gqqLogin?r=777151794&vdata='.md5(time());
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
//传递一个作为HTTP“POST”操作的所有数据的字符串。
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$out=curl_exec($ch);
curl_close($ch);
return $out;
}
?>